import { Fragment, useEffect, useState } from "react"
import { getCinema } from "../../api/mm"
import "./cinema.css"
import Cinlist from "../../component/cinlist"

function Cinema() {

  const [ticketFlag, setticketFlag] = useState(1)
  const [tCinema, settCinema] = useState([])
  const [tCinemaFilter, settCinemaFilter] = useState()

  useEffect(() => {
    // 挂载完成

    const fetchdata = async () => {
      const tCinema = (await getCinema({
        cityId: 440300,
        ticketFlag: 1
      })).data.cinemas;

      settCinema((prevState) => {
        return [
          ...prevState,
          ...tCinema
        ]
      })
    }

    fetchdata()
    // 卸载操作
    return () => {

    }
  }, [])

  return (
    <Fragment>
      <div className="Cinema-page">
        <div className="header-c">
          <li >{"深圳"}<i className="iconfont icon-xiala"></i></li>
          <li>影院</li>
          <li className="iconfont icon-sousuo"></li>
        </div>
        {/* <div className="cinema-list"></div> */}
      </div>
      {tCinema.length > 0 && (<Cinlist tCinema={tCinema} ticketFlag={ticketFlag}></Cinlist>)}
    </Fragment>
  )
}

export default Cinema